package com.gws.ievent.scheduler.timewheel;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

/**
 * @author song
 * @date 2022/10/27 11:05
 */
public class TimeWheelTest {

    public static void main(String[] args) throws IOException {
        TimeWheel timeWheel = new TimeWheel(128, 100, TimeUnit.MILLISECONDS);
        System.out.println(LocalDateTime.now().toString());

        timeWheel.addTask(() -> {
            System.out.println(100 + ": " + LocalDateTime.now().toString() + "======" + timeWheel.getRunTasks());
        }, 150, TimeUnit.MILLISECONDS);

        for (int i = 0; i < 1000000; i++) {
            int i1 = 100 + (int)(Math.random() * 18000);

            timeWheel.addTask(() -> {
                System.out.println(i1 + ": " + LocalDateTime.now().toString() + "======" + timeWheel.getRunTasks());
            }, i1, TimeUnit.MILLISECONDS);
        }

        System.in.read();
        System.out.println(22222);
    }

}
